//
// Created by lenovo on 2024/1/12.
//

#ifndef CALCULATOR_LEXER_H
#define CALCULATOR_LEXER_H

#include "../import.h"
#include <utility>
#include <vector>


class Lexer {
public :
    Evaluable* root() ;
    explicit Lexer(
            std::vector<token*> tks,
            std::map<std::string ,Functions::iFunction*>* _map,
            std::vector<std::set<std::string> >* prio = &Priority::OptPrio
                    )
                    : tokens(std::move(tks)) , priority(prio) , _identified_funcs(_map)
                    {}
protected:
public :
    std::vector<token*> tokens ;
    void negationOptimize() ;//取反优化
    void bracketConvert() ;
    void funcExtract() ;
    void check  () ;
    void Build  () ;
    std::vector< std::set<std::string> >* priority {nullptr} ;//定义了运算符的优先级
    std::map< std::string , Functions::iFunction*>* _identified_funcs;//需要用到的函数
};


#endif //CALCULATOR_LEXER_H
